class Task55_2:
    def run(self, tree):
        result, depth = self.postorder(tree)
        return result

    def postorder(self, node):
        if node is None:
            return True, 0
        else:
            left_result, left_depth = self.postorder(node.left)
            right_result, right_depth = self.postorder(node.right)
            if (left_depth - 1) <= right_depth <= (left_depth + 1):
                result = (left_result and right_result)
            else:
                result = False
            return result, max(left_depth, right_depth) + 1
